package controller;

import java.io.IOException;

import javax.servlet.ServletException;
import javax.servlet.http.HttpServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;

import file.DownloadLogic;

public class FileDownloadController extends HttpServlet {
	
	private static final long serialVersionUID = 1L;

	public FileDownloadController() {
		
		
	}
	
	@Override
	protected void doGet(HttpServletRequest req, HttpServletResponse resp)
			throws ServletException, IOException {
			
			req.setCharacterEncoding("utf-8");
			doPost(req, resp);
	}
	
	@Override
	protected void doPost(HttpServletRequest req, HttpServletResponse resp)
			throws ServletException, IOException {
		
		req.setCharacterEncoding("utf-8");
		
		String filename = req.getParameter("filename");
		
		try {
			DownloadLogic.download(filename, req, resp);
		} catch (Exception e) {
			e.printStackTrace();
		}
	}
}
